#ifndef AFE_CMD_H_
#define AFE_CMD_H_

#include <stdint.h>
#include "spi_dev_ctl.h"
#include "usr_typedef.h"

#define AFE_CH_0 	((uint16_t)0x0001)   /*!< CH 0 selected */
#define AFE_CH_1 	((uint16_t)0x0002)   /*!< CH 1 selected */
#define AFE_CH_2 	((uint16_t)0x0004)   /*!< CH 2 selected */
#define AFE_CH_3 	((uint16_t)0x0008)   /*!< CH 3 selected */
#define AFE_CH_4 	((uint16_t)0x0010)   /*!< CH 4 selected */
#define AFE_CH_5 	((uint16_t)0x0020)   /*!< CH 5 selected */
#define AFE_CH_6 	((uint16_t)0x0040)   /*!< CH 6 selected */
#define AFE_CH_7 	((uint16_t)0x0080)   /*!< CH 7 selected */
#define AFE_CH_8 	((uint16_t)0x0100)   /*!< CH 8 selected */
#define AFE_CH_9 	((uint16_t)0x0200)   /*!< CH 9 selected */
#define AFE_CH_10 	((uint16_t)0x0400)  /*!< CH 10 selected */
#define AFE_CH_11 	((uint16_t)0x0800)  /*!< CH 11 selected */
#define AFE_CH_12 	((uint16_t)0x1000)  /*!< CH 12 selected */
#define AFE_CH_13 	((uint16_t)0x2000)  /*!< CH 13 selected */
#define AFE_CH_14 	((uint16_t)0x4000)  /*!< CH 14 selected */
#define AFE_CH_15 	((uint16_t)0x8000)  /*!< CH 15 selected */
#define AFE_CH_ALL 	((uint16_t)0xFFFF) /*!< All CH selected */

#define AFE_SPD_0 	((uint16_t)0x0001)
#define AFE_SPD_1 	((uint16_t)0x0002)
#define AFE_SPD_ALL ((uint16_t)0x0003) //! 双转速通道

typedef enum
{
    PGA_GAIN_DIV_8 		= '0',   /*!< pga gain: 1/8 */
    PGA_GAIN_DIV_4 		= '1',   /*!< pga gain: 1/4 */
    PGA_GAIN_DIV_2 		= '2',   /*!< pga gain: 1/2 */
    PGA_GAIN_DIV_1 		= '3',   /*!< pga gain: 1 */
    PGA_GAIN_MUL_2 		= '4',   /*!< pga gain: 2 */
    PGA_GAIN_MUL_4 		= '5',   /*!< pga gain: 4 */
    PGA_GAIN_MUL_8 		= '6',   /*!< pga gain: 8 */
    PGA_GAIN_MUL_16 	= '7',  /*!< pga gain: 16 */
    PGA_GAIN_MUL_32 	= '8',  /*!< pga gain: 32 */
    PGA_GAIN_MUL_64 	= '9',  /*!< pga gain: 64 */
    PGA_GAIN_MUL_128 	= ':', /*!< pga gain: 128 */
} pga_gain_e;


typedef enum
{
    CHX_MODE_SAFE 		= '0',  /*!< default mode */
    CHX_MODE_IEPE 		= '1', 	/*!< iepe acc mode */
    CHX_MODE_DC 		= '2',  /*!< dc mode */
    CHX_MODE_AC 		= '3',  /*!< ac mode */
    CHX_MODE_TIB 		= '4',  /*!< test mode */
    CHX_MODE_CAL 		= '5',  /*!< calibration mode */
} chx_mode_e;


typedef enum
{
    SPDX_MODE_SAFE 		= '0', 	/*!< default mode */
    SPDX_MODE_MAG 		= '1', 	/*!< megnetic speed mode */
    SPDX_MODE_OPT 		= '2', 	/*!< optics speed mode */
    SPDX_MODE_TIB 		= '3', 	/*!< test in board speed mode */
} spdx_mode_e;


typedef enum
{
    SAMP_51K2 			= '0',  /*!< default 51.2K SAMPRATE */
    SAMP_102K4 			= '1',  /*!< default 102.4K SAMPRATE */
    SAMP_204K8 			= '2', 	/*!< 204.8K SAMPRATE */
    SAMP_409K6 			= '3', 	/*!< 409.6K SAMPRATE */
} samp_freq_e;

int afe_acq_begin(afe_dev_info *afe_dev);
int afe_acq_stop(afe_dev_info *afe_dev);
int afe_tib_begin(afe_dev_info *afe_dev);
int afe_tib_stop(afe_dev_info *afe_dev);
void afe_get_fw(afe_dev_info *afe_dev, char afe_fw[]);
int afe_pwr_off(afe_dev_info *afe_dev);
int afe_set_chx_gain(afe_dev_info *afe_dev, uint16_t chx, pga_gain_e gain);
int afe_get_chx_gain(afe_dev_info *afe_dev, uint16_t chx, pga_gain_e *gain);
int afe_set_chx_mode(afe_dev_info *afe_dev, uint16_t chx, chx_mode_e mode);
int afe_get_chx_mode(afe_dev_info *afe_dev, uint16_t chx, chx_mode_e *mode);
int afe_set_spdx_mode(afe_dev_info *afe_dev, uint16_t spdx, spdx_mode_e mode);
int afe_set_samp_freq(afe_dev_info *afe_dev, samp_freq_e samp_freq);
int afe_get_samp_freq(afe_dev_info *afe_dev, samp_freq_e *samp_freq);
int afe_get_state(afe_dev_info *afe_dev, uint8_t afe_state[]);


#endif
